﻿using Base.Infrastructure.Dto.Request.option;
using Base.Service.Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Base.Api.Admin.Controllers
{
    [Route("api/[controller]/[action]")]
    /*[ApiExplorerSettings(GroupName = "Examination")]*///分组
    [ApiController]
    public class UserExamController : BaseController
    {
        private readonly IUserExamService _userExamService;

        public UserExamController(Base.Service.Interface.IUserExamService userExamService)
        {
            _userExamService = userExamService;
        }

        /// <summary>
        /// 获取该用户的已结束的考试信息，Uescore/考试得分，Uestate/考试状态(-1:待考试/0:正在考试/1:已交卷/2:缺考)
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        //[Authorize]
        public IActionResult Querytest(string UEUID) {
            var result = _userExamService.Querytest(UEUID);
            return Ok(result);
        }

        /// <summary>
        /// 获取用户未完成的考试，Uestate/考试状态(-1:待考试/0:正在考试/1:已交卷/2:缺考)
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        //[Authorize]
        public IActionResult Unfinishedexams(string UEUID)
        {
            var result = _userExamService.Unfinishedexams(UEUID);
            return Ok(result);
        }

        /// <summary>
        /// （开始考试）根据考试id获取题目 返回值:Qid/题目id，Qcontent/题目，Ocontent里面的参数:Oid/选项ID，Oqid/题目ID，Qtype/题目类型，Ocontent/选项内容，OisRight/是否是正确答案，TPDScore/题目分数，TimeRemaining/考试剩余时间
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        //[Authorize]
        public IActionResult GetExamQuestions(string UEID)
        {
            var result = _userExamService.GetExamQuestions(UEID);
            return Ok(result);
        }

        /// <summary>
        /// （交卷）参数：OID/所有选择的答案ID，UEID/考试ID，OQID/不需要填写
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        //[Authorize]
        public IActionResult Submit(OcontentRequestDto dto)
        {
            var result = _userExamService.Submit(dto);
            return Ok(result);
        }
    }
}
